package com.xiyu.service.repository.customer.contact;

import com.xiyu.service.model.customer.contact.CustomerContactBusinessCard;
import com.xiyu.service.model.customer.contact.CustomerContactBusinessCardTable;
import org.babyfish.jimmer.spring.repository.JRepository;

import java.util.List;

public interface CustomerContactBusinessCardRepository extends JRepository<CustomerContactBusinessCard, Long> {
    CustomerContactBusinessCardTable customerContactBusinessCardTable = CustomerContactBusinessCardTable.$;

    default void deleteByCustomerIds(List<Long> customerIds){
        sql().createDelete(customerContactBusinessCardTable)
                .where(customerContactBusinessCardTable.contact().customerId().in(customerIds))
                .execute();
    }

    default void deleteByExcludeId(Long contactId, List<Long> ids){
        sql().createDelete(customerContactBusinessCardTable)
                .where(customerContactBusinessCardTable.contactId().eq(contactId))
                .where(customerContactBusinessCardTable.id().notIn(ids))
                .execute();
    }

    List<CustomerContactBusinessCard> findByContactId(Long contactId);


}